package com.itheima.controller;

<<<<<<< HEAD
import com.github.pagehelper.PageInfo;
import com.itheima.domain.Product;
import com.itheima.util.BeanUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/controll/*")
public class ProductServlet extends BaseServlet {
    public void  findAll(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String pageNum = req.getParameter("pageNum");
        String pageSize = req.getParameter("pageSize");
       List<Product> list= product.findAll(pageNum,pageSize);
        PageInfo<Product> pageInfo = new PageInfo<>(list);
        req.setAttribute("page",pageInfo);
        //??????
        req.getRequestDispatcher("/pages/product-list.jsp").forward(req,resp);
    }
    //????
    public void save(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Product pro = BeanUtil.fillBean(req, Product.class,"yyyy-MM-dd HH:mm");
       product.save(pro);
        findAll(req,resp);
    }
    //??id????
    public void  deleteByIds(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //?????????ids
        String ids = req.getParameter("ids");
        product.deleteByIds(ids);
        findAll(req,resp);
    }
    //????
    public void  update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //BeanUtil??????????
        Product pro= BeanUtil.fillBean(req, Product.class,"yyyy-MM-dd HH:mm");
        //???????update????
        product.update(pro);
    }
=======
public class ProductServlet extends BaseServlet {
>>>>>>> 87a0f68c2b3b7de3b37de1968a6eac4ab534cee5
}
